<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%--使用taglib 引入标签库--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  <meta name="renderer" content="webkit">
  <title>用户管理-编辑信息</title>
  <link rel="stylesheet" href="<c:url value="/css/pintuer.css"/>">
  <link rel="stylesheet" href="<c:url value="/css/user.css"/>">
  <script src="<c:url value="/js/jquery.js"/>"></script>
  <script src="<c:url value="/js/pintuer.js"/>"></script>
</head>
<body>
<div class="panel admin-panel">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>编辑用户</strong></div>
  <div class="body-content">
    <form id="editForm" method="post" class="form-x" action="index" onsubmit="submitToParent(event)">
      <div class="form-group">
        <div class="label">
          <label>用户编号：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="${user.userid}" readonly="readonly" name="userid" data-validate="required:请输入用户编号" />
          <div class="tips"></div>
        </div>
      </div>

      <div class="form-group">
        <div class="label">
          <label>姓名：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="${user.fullname}" name="fullname" data-validate="required:请输入姓名" />
          <div class="tips"></div>
        </div>
      </div>

      <div class="form-group">
        <div class="label">
          <label>密码：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="${user.password}" name="password" data-validate="required:请输入密码" />
          <div class="tips"></div>
        </div>
      </div>

      <div class="form-group">
        <div class="label">
          <label>电话号码：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="${user.telephone}" name="telephone" data-validate="required:请输入电话号码" />
          <div class="tips"></div>
        </div>
      </div>

      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main icon-check-square-o" type="submit"> 提交</button>
        </div>
      </div>
    </form>
  </div>
</div>
<script type="text/javascript">
  window.onload = function () {
    // 使用 JSTL 判断并插入操作结果
    <c:if test="${operation == 'success'}">
    alert("操作成功！");
    </c:if>
    <c:if test="${operation == 'failure'}">
    alert("操作失败，错误信息：${message}");
    </c:if>
  };
  //提交表单给父页面的函数
  function submitToParent(event){
    event.preventDefault(); // 防止表单默认提交
    // 获取父页面的form对象
    window.top.submitForm(document.getElementById("editForm"));
  }
</script>
</body></html>
